
cmake_minimum_required(VERSION 3.4.1)


add_library(
             ffmpeg_player

             SHARED

            src/main/cpp/video.cpp src/main/cpp/BlockingQueue.cpp
             src/main/cpp/video.cpp src/main/cpp/Audio.cpp
              src/main/cpp/Player.cpp
              src/main/cpp/queue.c
              src/main/cpp/ffmpeg_player.cpp


              )

#add_library(
#             live
#
#             SHARED
#
#            #src/main/cpp/video.cpp src/main/cpp/queue.c
#            src/main/cpp/video.cpp src/main/cpp/dn_live.cpp
#
#              )


#SHARED：表示.so的库。
#${CMAKE_SOURCE_DIR}：表示CMake.txt的当前文件夹路径。
#${ANDROID_ABI}：编译时会自动根据CPU架构去选择相应的库。

#添加第三方库
add_library(avcodec-56 SHARED IMPORTED)
set_target_properties(avcodec-56
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libavcodec-56.so)

add_library(avdevice-56 SHARED IMPORTED)
set_target_properties(avdevice-56
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libavdevice-56.so)

add_library(avfilter-5 SHARED IMPORTED)
set_target_properties(avfilter-5
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libavfilter-5.so)

add_library(avformat-56 SHARED IMPORTED)
set_target_properties(avformat-56
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libavformat-56.so)

add_library(avutil-54 SHARED IMPORTED)
set_target_properties(avutil-54
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libavutil-54.so)

add_library(postproc-53 SHARED IMPORTED)
set_target_properties(postproc-53
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libpostproc-53.so)

add_library(swresample-1 SHARED IMPORTED)
set_target_properties(swresample-1
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libswresample-1.so)

add_library(swscale-3 SHARED IMPORTED)
set_target_properties(swscale-3
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libswscale-3.so)

add_library(yuv SHARED IMPORTED)
set_target_properties(yuv
  PROPERTIES IMPORTED_LOCATION
  ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libyuv.so)

  add_library(x264 STATIC IMPORTED)
  set_target_properties(x264
    PROPERTIES IMPORTED_LOCATION
    ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libx264.a)

    add_library(faac STATIC IMPORTED)
    set_target_properties(faac
      PROPERTIES IMPORTED_LOCATION
      ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libfaac.a)

  add_library(rtmp SHARED IMPORTED)
    set_target_properties(rtmp
    PROPERTIES IMPORTED_LOCATION
    ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/librtmp.so)

#引入的库文件需要头文件
include_directories(
${ANDROID_NDK}/sources/cxx-stl/stlport/stlport
${CMAKE_SOURCE_DIR}/src/main/cpp/include
${CMAKE_SOURCE_DIR}/src/main/cpp/x264
${CMAKE_SOURCE_DIR}/src/main/cpp/faac
)

#${ANDROID_NDK}/sources/cxx-stl/stlport/stlport/

#添加系统库
find_library( log-lib
              log )

#添加系统库
find_library( android-lib
              android )

#添加系统库
find_library( libstlport_shared-lib
              libstlport_shared )



#需要编译进来的库
target_link_libraries( # Specifies the target library.
                       ffmpeg_player
                       #live

                       avcodec-56
                       avdevice-56
                       avfilter-5
                       avformat-56
                       avutil-54
                       postproc-53
                       swresample-1
                       swscale-3
                       yuv
                       x264
                       faac
                       rtmp

                       ${log-lib}
                        ${android-lib}

                        )

